//APP更新
import config from '@/config.js'
import http from '@/utils/request'
export default function appUpdate() {
	http.request({
		url:'/erp/common/app/version/latestVersion', //检查更新的服务器地址
	}).then(res => {
		console.log('res',res)
		plus.runtime.getProperty(plus.runtime.appid, function(wgtinfo) {
			const serviceVersion = res.data.result.versionCode
			let client_version = wgtinfo.version
			var flag_update = client_version != serviceVersion
			console.log(client_version)
			console.log(flag_update)
			console.log(res)
			if(flag_update){			
				const fileNo = res.data.result.appFile
				const obj = {
					describe:'版本升级'+serviceVersion,
					edition_url:config.baseUrl+'/file/download/'+fileNo,
					edition_force:1,
					package_type:0
				}
				uni.navigateTo({
					url: '/components/rt-uni-update/components/rt-uni-update/rt-uni-update?obj=' +
								JSON.stringify(obj)
				});
			}
		
		});
	})
}
